 
 
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>聊天记录</title>

  <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css">
<style>
body .layim-chat-main{height: auto;}
</style>
</head>
<body>

<div class="layim-chat-main">
  <ul id="LAY_view"></ul>
</div>

<div id="LAY_page" style="margin: 0 10px;"></div>

<textarea title="消息模版" id="LAY_tpl" style="display:none;">
{{# layui.each(d.data, function(index, item){
  if(item.mine){ }}
    <li class="layim-chat-mine"><div class="layim-chat-user"><img src="{{ item.avatar }}"><cite><i>{{ layui.data.date(item.timestamp) }}</i>{{ item.username }}</cite></div><div class="layim-chat-text">{{ layui.layim.content(item.content) }}</div></li>
  {{# } else { }}
    <li><div class="layim-chat-user"><img src="{{ item.avatar }}"><cite>{{ item.username }}<i>{{ layui.data.date(item.timestamp) }}</i></cite></div><div class="layim-chat-text">{{ layui.layim.content(item.content) }}</div></li>
  {{# }
}); }}
</textarea>
<script src="/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
  base: '/layuiadmin/'//静态资源所在路径
}).extend({
  CoreUtil : 'core-util/CoreUtil'
}).use(['layim', 'laypage','CoreUtil'], function(){
  var layim = layui.layim
  ,layer = layui.layer
  ,laytpl = layui.laytpl
  ,$ = layui.jquery
  ,CoreUtil = layui.CoreUtil
  ,laypage = layui.laypage;

  function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
    var r = window.location.search.substr(1).match(reg);
    if (r!=null) return (r[2]); return null;
  }

  CoreUtil.sendAjax("/manager/chat/history/"+GetQueryString("id"),{},function (res) {
    var html = laytpl(LAY_tpl.value).render({
      data: res.data
    });
    $('#LAY_view').html(html);
  },"GET",'application/json; charset=UTF-8',false);
});
</script>
</body>
</html>
